// 基于准备好的dom，初始化echarts实例
var myChart4 = echarts.init(document.getElementById("right-bottom"),'dark');
// 指定图表的配置项和数据
var returnData = {
    day: [],
    confirm: [],
    suspect: [],
    cured: [],
    death: [],
}
$.ajax({
    url: '/data_usa',
    method: 'GET',
    dataType: 'json',
    success: function (data) {
        returnData.day = data.day;
        returnData.confirm = data.confirm;
        returnData.suspect = data.suspect;
        returnData.cured = data.cured;
        returnData.death = data.death;
        var option = {
            title: {
                text: '美国02-11⽉疫情情况',
                subtext: '数据截⽌⽇期：2020-11',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                show: false
            },
            grid: {
                left: '1%',
                right: '10%',
                top: '12%',
                containLabel: true
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: returnData.day,
                name: '月份'
            },
            yAxis: {
                splitLine: { show: false },
                name: '人数'
            },
            series: [{
                name: '确诊人数',
                showSymbol: false,
                type: 'line',
                data: returnData.confirm

            },
            {
                name: '感染人数',
                type: 'line',
                showSymbol: false,
                data: returnData.suspect
            },
            {
                name: '治愈人数',
                type: 'line',
                showSymbol: false,
                data: returnData.cured
            },
            {
                name: '死亡人数',
                type: 'line',
                showSymbol: true,
                data:returnData.death
            }
            ]



        };

        // 使用刚指定的配置项和数据显示图表。
        myChart4.setOption(option);
    },
    error: function (msg) {
        console.log(msg)
    }
});